<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 1 echarts 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">

</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>统计分析<small>会员数量</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员数量</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 2 为 ECharts 准备一个具备大小（宽高）的 DOM id="chart1" style="height:600px;" -->
            <div id="chart1" style="/*width: 600px;*/height:600px;"></div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../plugins/echarts/echarts.js"></script>
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script type="text/javascript">
    // 3 基于准备好的dom，初始化echarts实例
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('chart1'));
    var option = {
        title: {
            text: '会员数量',
            left: '1%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: { type: 'cross' }
        },
        legend: {},
        xAxis: {
            type: "category",
            data: []
        },
        yAxis: {},
        series: [{
            data: [],
            name: '会员数量',
            type: "line"
        }]
    };
            axios.get("/report/getMemberReport").then((rs) => {
                let memberCount = [];
                let months = [];
                for (let i = 0; i < rs.data.data.months.length; i++) {
                    months.push(rs.data.data.months[i]);
                    memberCount.push(rs.data.data.memberCount[i]);
                }
                console.log(memberCount);
                console.log(months)
                myChart.setOption({
                    xAxis: {
                        type: "category",
                        data: months
                    },
                    series: [{
                        data: memberCount
                    }]
                })
            })
    //     /*异步请求*/
    //     axios.get("/report/getSetmealReport").then((rs) => {
    //     /*console.log(rs.data.data.setmealNames);
    //     console.log(rs.data.data.setmealCount);*/
    //     let setData = [];
    //     for (let i = 0; i < rs.data.data.setmealNames.length; i++) {
    //     let setmeal = {};
    //     setmeal.name = rs.data.data.setmealNames[i];
    //     setmeal.value = rs.data.data.setmealCount[i];
    //     setData.push(setmeal);
    // }
    //     console.log(setData)
    //     /*设置echats配置与数据*/
    //     myChart.setOption({
    //     legend: {
    //     orient: "vertical",
    //     left: "left",
    //     data: setData
    // },
    //     series: [
    // {
    //     type: 'pie',
    //     data: setData
    // }
    //     ]
    // })
    // })

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    // 4 发送ajax请求,获取结果, 使用刚指定的配置项和数据显示图表。

</script>
</html>
